import { observable } from "mobx";
import { message, Modal } from "antd";
// const { confirm } = Modal;
import { ExclamationCircleOutlined } from '@ant-design/icons';
import { history } from "umi";
import indexStore from "../pages/model"
let admin = '';
let host = '';


//区分调试环境和发布的环境
// if (process.env.NODE_ENV === 'development') {

//   admin = `http://${IP}:9083/hospital-service/admin`;
//   host = `http://${IP}:9083/hospital-service`;
//   // admin = '/api/hospital-service/admin'
//   // host = '/api/hospital-service'
// } else {
//   //admin='http://192.168.0.220:8080/admin'
//   //admin = '/nginxapi/hospital-service/admin';
//   //host = '/nginxapi/hospital-service';
//   // admin = 'http://192.180.3.199:9083/hospital-service/admin';
//   // host = 'http://192.180.3.199:9083/hospital-service';
//   admin = `${IP}/admin`;
//   host = IP;
// }

let systemPower = admin + '/system';


const api = observable({

  // // 设备端接口
  // // 指纹管理
  // personPatientList: `${admin}/patient/pageList`,//获取病人列表  POST
  // fingerPrintList: `${host}/admin/patient/fingerprint/pageList`, // 获取列表
  // fingerPrintDetail: `${host}/admin/patient/fingerprint/getByPatientId`, // 获取用户指纹信息
  // delFingerPrint: `${host}/admin/patient/fingerprint`, // 删除指纹
  // addFingerPrint: `${host}/util/fingerprint/upload`, //新增患者指纹信息


  // register: `${host}/util/token/register`,  // 设备注册获取token
  // getPrescription: `${host}/util/miniSoft/getPrescription`,  // 方获取处
  // fingerprintFile: `${host}/util/fingerprint/export`,  // 指纹文件下载
  // dayFingerprint: `${host}/util/fingerprint/fingerprintInfoList`,  // 当日新增指纹数据导入

  IP: "http://192.180.3.199:9083/hospital-service",

  // 方法
  personPatientList() {
    return `${api.IP}/admin/patient/pageList`
  },
  fingerPrintList() {
    return `${api.IP}/admin/patient/fingerprint/pageList`
  },
  fingerPrintDetail() {
    return `${api.IP}/admin/patient/fingerprint/getByPatientId`
  },
  delFingerPrint() {
    return `${api.IP}/admin/patient/fingerprint`
  },
  addFingerPrint() {
    return `${api.IP}/util/fingerprint/upload`
  },
  getPrescription() {
    return `${api.IP}/util/miniSoft/getPrescription`
  },
  fingerprintFile() {
    return `${api.IP}/util/fingerprint/export`
  },
  dayFingerprint() {
    return `${api.IP}/util/fingerprint/fingerprintInfoList`
  },
  // 更新处方状态
  changePrescriptionState() {
    return `${api.IP}/util/miniSoft/completeCure`
  },
  register() {
    return `${api.IP}/util/token/register`
  },
  // 登录
  login() {
    return `${api.IP}/admin/system/login/loginByWeb`
  },
  // 获取字典
  getDict() {
    return `${api.IP}/admin/system/codeType/getPageList`
  },

  // 初始化ip
  setIP() {
    let IP = JSON.parse(localStorage.getItem("device"))?.IP
    if (IP) {
      api.IP = `http://${IP}:9083/hospital-service`
    } else {
      // 如果有ip一开始就是黑屏状态
      indexStore.state = 100
      // message.info("请先设置设备IP和编号")
      Modal.confirm({
        title: '请先设置设备IP和编号',
        // icon: <ExclamationCircleOutlined />,
        content: '是否前往设置？',
        onOk() {
          history.push("/tokenIP")
        },
        onCancel() {
          console.log("cancel")
        }
      })
    }
  },



  //imagehost: "http://yf.yrdosf.com:6020",//,//"http://yf.yrdosf.com:6005",//"http://192.168.0.118:8083",//
  imagehost: "http://192.230.10.230",
  loginByWeb: `${systemPower}/login/loginByWeb`, //用户登录接口   POST
  getRouters: `${systemPower}/login/getRouters`, //获取路由信息   GET
  getInfo: `${systemPower}/login/getInfo`, //获取用户信息   GET

  menuMenuId: `${systemPower}/menu/menuId`, //根据菜单Id获取菜单详细信息   GET
  menuList: `${systemPower}/menu/list`, //获取菜单列表   GET
  menuRoleMenuTreeSelect: `${systemPower}/menu/roleMenuTreeSelect/`, //对应角色菜单列表树   GET {roleId}
  menuTreeSelect: `${systemPower}/menu/treeSelect`, //获取菜单下拉树列表   GET
  menu: `${systemPower}/menu`,
  logout: `${systemPower}/login/logout`, //用户退出接口  POST

  deviceList: `${admin}/deviceInfo/pageList`,//获取设备列表 POST
  device: `${admin}/deviceInfo/`,//删除 设备列表 POST DELETE /device/{id}
  deviceEdit: `${admin}/deviceInfo`,//修改 PUT 传ID
  deviceGet: `${admin}/deviceInfo/getById/`,//修改 get 传ID
  devicePatientQueue: `${admin}/deviceInfo/devicePatientQueue/`,//{uniqueCode}
  refreshDeviceListCache: `${admin}/deviceInfo/refreshDeviceListCache`,//get

  personPatient: `${admin}/patient/`,//删除 病人列表 POST DELETE /patient/{id}
  personPatientEdit: `${admin}/patient`,//修改 Put 传ID
  personPatientAdd: `${admin}/patient`,// 新增 post 不传ID
  personTmsOrMepPatientList: `${admin}/patient/patientList`,// 患者列表
  personBindHIdOrOId: `${admin}/patient/bindHIdOrOId`,// 绑定患者


  personPatientDetailEdit: `${admin}/tmsCureRecord`,//修改治疗记录`,//修改 put 传ID  --
  getCureRecordTemplate: `${admin}/tmsCureRecord/pageList`,//空白治疗记录单下载 {patientId}  --
  getTmsCureRecordByUserId: `${admin}/tmsCureRecord/pageList`,//获取 {patientId}  --
  deleteTmsCureRecord: `${admin}/tmsCureRecord/`,//删除资料记录 {id}  ----
  getTmsCureRecord: `${admin}/tmsCureRecord/pageList`,//查询患者治疗记录列表 {patientId}  --
  listTmsRecordByPatientId: `${admin}/tmsCureRecord/listTmsRecordByPatientId`,//根据患者ID查询治疗记录(报告服务) {patientId}  --

  listMepRecordByCode: `${admin}/mepCureRecord/listMepCureRecord/`,//获取患者MEP治疗记录 {code}  --


  hardwaretreatmentRecord: `${admin}/hardware/treatmentRecord`,//根据患者id返回Pdf {patientId}  --
  getTmsCureRecordToHis: `${admin}/his/getTmsCureRecordToHis`,//获取 {patientId}  --===
  histreatmentRecord: `${admin}/his/treatmentRecord`,//根据患者patientNo返回Pdf {patientId} --===
  pdaGetDeviceId: `${admin}/pda/device/getDeviceId`,//获取设备列表  ---



  //治疗计划
  planList: `${admin}/plan/pageList`,//获取列表 POST
  planDelete: `${admin}/plan/`,//删除 列表 POST DELETE /user/{id}
  planEdit: `${admin}/plan`,//修改 PUT 传ID
  planAdd: `${admin}/plan`,//修改 Post 传ID


  dataDictGet: `${systemPower}/codeType/`,//删除 GET /codeType/{id}
  dataDictList: `${systemPower}/codeType/getPageList`,//修改 post 传ID
  dataDictDelete: `${systemPower}/codeType/`,//删除 DELETE /codeType/{id}
  dataDictEdit: `${systemPower}/codeType/saveOrUpdate`,//修改 post 传ID
  dataDictAdd: `${systemPower}/codeType/saveOrUpdate`,//新增 post 不传ID

  codeValue: `${systemPower}/codeValue/`,//删除 DELETE /codeType/{id}
  codeValueEdit: `${systemPower}/codeValue/saveOrUpdate`,//修改 post 传ID
  codeValueAdd: `${systemPower}/codeValue/saveOrUpdate`,//新增 post 不传ID

  //系统用户相关接口
  sysUser: `${systemPower}/sysUser`,//
  sysUserChangeStatus: `${systemPower}/sysUser/changeStatus`,//状态修改 PUT
  sysUserList: `${systemPower}/sysUser/list`,//状态修改 PUT
  sysUserResetPwd: `${systemPower}/sysUser/resetPwd`,//重置密码 PUT
  updatePwd: `${systemPower}/sysUser/updatePwd`,//修改密码 PUT
  uploadAutograph: `${systemPower}/sysUser/uploadAutograph`,//上传签名 POST {userId}


  //权限相关
  role: `${systemPower}/role`,
  roleList: `${systemPower}/role/list`,
  roleDataScope: `${systemPower}/role/dataScope`,//修改数据 PUT
  roleMenuTreeSelect: `${systemPower}/menu/roleMenuTreeSelect`,

  //日志相关
  getHardLog: `${admin}/log/getHardLog`,// --
  getLoginLog: `${admin}/log/getLoginLog`, // --
  getOperationLog: `${admin}/log/getOperationLog`, //---
  logList: `${admin}/log/getPageList`,  //获取列表 POST --
  deviceLogsList: `${admin}/log/getPageList`,  //获取日志的接口 GET  --
  systemLogsList: `${admin}/log/getPageList`,  //获取日志的接口 GET  ---


  menuManageList: `${systemPower}/userInfo/firstGetMenu`,  //登录完成查询菜单 GET
  menuInfoDelete: `${systemPower}/menuInfo/delete`,  //菜单删除数据 DELETE
  menuInfoGetById: `${systemPower}/menuInfo/getById/`,  //通过主键查询单条数据 menuInfo/getById/{id} GET
  menuInfoInsert: `${systemPower}/menuInfo/insert`,  //菜单新增数据 POST
  menuInfoUpdate: `${systemPower}/menuInfo/update`,  //菜单修改数据 PUT


  roleManageList: `${systemPower}/roleInfo/selectPage`,//获取列表 GET
  roleManageEdit: `${systemPower}/roleInfo/update`,//修改 PUT 传ID
  roleManageAdd: `${systemPower}/roleInfo/insert`,//新增 post
  roleManageGet: `${systemPower}/roleInfo/getById/`,//查询单个 {id}
  roleManageDel: `${systemPower}/roleInfo/delete`,//删除单个 delete
  roleManageBindMenu: `${systemPower}/roleInfo/bindMenu`,//角色绑定菜单 POST

  roleManageBoundIdList: `${systemPower}/roleInfo/showBoundId?id=`,//已绑定菜单id集合 GET  --

  ///configuration/{id}
  // 删除配置

  configurationList: `${systemPower}/configuration/getPageList`,//修改 PUT
  configurationDelete: `${systemPower}/configuration/`,//删除 DELETE {id}
  configurationSaveOrUpdate: `${systemPower}/configuration/saveOrUpdateConfiguration`,//配置新增或修改（入参是否有id区分）
  configurationGetOne: `${systemPower}/configuration/getOne/`,//获取单条信息配置详情 {configName}

  maintainInitData: `${systemPower}/maintain/initData/yrd@123`,//出厂设置
  patientEndOfTreatment: `${admin}/patient/endOfTreatment/0`,//疗程结束



  //医生信息
  doctorList: `${admin}/doctorInfo/pageList`,//获取列表 POST
  doctorDelete: `${admin}/doctorInfo/`,//删除 列表 POST DELETE /user/{id}
  doctorEdit: `${admin}/doctorInfo`,//修改 PUT 传ID
  doctorAdd: `${admin}/doctorInfo`,//修改 Post 传ID

  //统计
  getStatistics: `${admin}/statistics/getStatistics`,//修改 get

  //大屏
  listDeviceMonitor: `${host}/largeScreen/listDeviceMonitor`,//修改 get


  //PDA接口
  pdaGetPatient: `${host}/pda/patient/getPatient`, //get
  pdaGetPatientByHospitalizationId: `${host}/pda/patient/getPatientByHospitalizationId`, //get
  pdaArrangeDevice: `${host}/pda/device/arrangeDevice`, //post
  pdaCleanArrangeCure: `${host}/pda/device/cleanArrangeCure?uniqueCode=`, //delete
  pdaListDevice: `${host}/pda/device/listDevice/1`,  //get
  patientGetPatient: `${admin}/patient/getPatient`,//获取 POST


  //查询患者的跟踪治疗故事线
  recordList: `${admin}/record/list/`,//get patientId


  //新tdcs接口  tdcsCureRecord/insert
  zlapi_pageByPatientId: '/zlapi/znion-rainbow/tdcsCureRecord/pageByPatientId',
  zlapi_curerecordupdate: '/zlapi/znion-rainbow/tdcsCureRecord/update',
  zlapi_curerecorddeleteById: '/zlapi/znion-rainbow/tdcsCureRecord/deleteById/',
  zlapi_curerecorddownload: '/zlapi/znion-rainbow/tdcsCureRecord/download',

  //近红外接口
  zlapi_bsCureRecordDown: '/zlapi/znion-rainbow/bsCureRecord/download', //get id=
  zlapi_bsCureRecordInsert: '/zlapi/znion-rainbow/bsCureRecord/insert', //post
  zlapi_bsCureRecordList: '/zlapi/znion-rainbow/bsCureRecord/list',  //get  patientId current endTime startTime  size


  //fns接口
  zlapi_smCureRecordList: '/zlapi/znion-rainbow/smCureRecord/listPage', //get
  zlapi_smCureRecordInsert: '/zlapi/znion-rainbow/smCureRecord/insert', //Post
  zlapi_smCureRecordDownload: '/zlapi/znion-rainbow/smCureRecord/download', //get  patientId


  /*age		query	false
  integer(int32)
  bedNum		query	false
  string
  department		query	false
  string
  diagnosis		query	false
  string
  hospitalizationId		query	false
  string
  name		query	false
  string
  outpatientId		query	false
  string
  sexStr*/


});


export default api;
